<template>
  <div class="left">
    <div class="currentInfo" v-show="currentPlayInfoIsShow">
      <div
        class="left hover-hand"
        @mouseenter="showMask"
        @mouseleave="showMask"
      >
        <div class="mask" v-show="maskIsShow" @click="showPlayingDetail">
          <i class="iconfont">&#xe820;</i>
        </div>
        <img :src="picUrl" />
      </div>
      <div class="right yahei">{{ musicName }}</div>
    </div>

    <i class="iconfont hover-hand" @click="preAndNext(-1)">&#xe6ba;</i>
    <i
      class="iconfont play hover-hand"
      v-show="toggleShowPlay"
      @click="togglePlay"
      >&#xe60c;</i
    >
    <i
      class="iconfont play hover-hand"
      v-show="!toggleShowPlay"
      @click="togglePlay"
    >
      &#xe606;
    </i>
    <i class="iconfont next hover-hand" @click="preAndNext(1)">&#xe6ba;</i>
  </div>
</template>

<script>
import bus from "utils/bus.js";
export default {
  name: "left",
  props: {
    currentPlayInfoIsShow: Boolean,
    picUrl: String,
    musicName: String,
    isPlaying: Boolean,
  },
  data() {
    return {
      toggleShowPlay: true,
      maskIsShow: false,
    };
  },
  methods: {
    togglePlay() {
      if (!this.musicName) {
        return;
      }
      this.toggleShowPlay = !this.toggleShowPlay;
      if (!this.toggleShowPlay) {
        this.$emit("play");
      } else {
        this.$emit("pause");
      }
    },

    preAndNext(t) {
      this.$emit("preAndNext", t);
    },

    showMask() {
      this.maskIsShow = !this.maskIsShow;
    },

    showPlayingDetail() {
      bus.$emit("showPlayingDetail");
    },
  },
  watch: {
    isPlaying(newValue) {
      this.toggleShowPlay = newValue;
    },
  },
};
</script>

<style scoped lang="less">
.left {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 0 0.166667rem 0 0.25rem;
  line-height: 0.541667rem;
  width: 2rem;
  height: 100%;
  i {
    font-size: 0.208333rem;
  }
  .play {
    font-size: 0.291667rem;
  }
  .next {
    transform: rotate(180deg);
  }
  .currentInfo {
    position: absolute;
    top: -0.541666rem;
    left: 0;
    display: flex;
    width: 100%;
    height: 0.541666rem;
    .left {
      position: relative;
      height: 100%;
      width: 0.541666rem;
      padding: 0.041666rem;
      border-radius: 0.166666rem;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
      .mask {
        position: absolute;
        top: 0.041666rem;
        left: 0.041666rem;
        right: 0.041666rem;
        bottom: 0.041666rem;
        font-size: 0.25rem;
        background: rgba(0, 0, 0, 0.3);
        color: white;
        line-height: 0.458417rem;
        text-align: center;
      }
    }
    .right {
      // flex-direction: column;
      line-height: 0.125rem;
      flex: 1;
      padding: 0.083333rem 0 0.083333rem 0.125rem;
    }
  }
}
</style>
